package com.gxuwz.manager.dao;

import java.sql.Connection;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.gxuwz.manager.model.Login;
import com.gxuwz.manager.util.DB;

public class LoginDao extends BaseDao{
	Connection conn = null;
	PreparedStatement ps = null;
    ResultSet rs = null;
    
    public Login login(String userId, String password){
    	String sql = "select * from login where user_id = '" + userId + "' and password = '" + password +"'";
    	ResultSet resultSet = query(sql);
    	try {
    		if(resultSet.next()){
				Login login = new Login();
				login.setId(resultSet.getInt("id"));
				login.setUserId(resultSet.getInt("user_id"));
				login.setPassWord(resultSet.getString("password"));
				login.setStatus(resultSet.getInt("status"));
				return login;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			DB.closeResultSet(rs);
		}
    	return null;
    }
}
